package org.jctc.els.modules.biz.service.elsUserProject.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import lombok.AllArgsConstructor;
import org.jctc.els.modules.biz.entity.ElsUserProject.ElsUserProject;
import org.jctc.els.modules.biz.entity.elsTeamMembers.ElsTeamMembersVO;
import org.jctc.els.modules.biz.entity.user.User;
import org.jctc.els.modules.biz.mapper.elsUserProject.ElsUserProjectMapper;
import org.jctc.els.modules.biz.service.elsUserProject.ElsUserProjectService;
import org.jctc.els.modules.biz.vo.ElsUserProjectVO;
import org.springblade.core.mp.base.BaseServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * @author maxinyu
 * @title: ElsUserProjectServiceImpl
 * @projectName evaluationsystem-boot
 * @description:
 * @date 2022/6/2110:13
 */
@Service
@AllArgsConstructor
public class ElsUserProjectServiceImpl extends BaseServiceImpl<ElsUserProjectMapper, ElsUserProject> implements ElsUserProjectService {
    @Autowired
    private ElsUserProjectMapper elsUserProjectMapper;

    @Override
    public IPage<ElsUserProjectVO> getProjectsList(IPage<ElsUserProjectVO> page, String teamId, String userId) {
        return page.setRecords(elsUserProjectMapper.getProjectsList(page,teamId,userId));
    }

    @Override
    public void removeListByIds(List<Long> ids) {
        for (int i = 0; i < ids.size(); i++) {
            elsUserProjectMapper.removeListByIds(ids.get(i));
        }
    }

    @Override
    public ArrayList<ElsUserProject> selectProjectByUserId(Long userId) {
        return elsUserProjectMapper.selectProjectByUserId(userId);
    }

    @Override
    public ElsUserProject selectUserProject(Long aLong) {
        return elsUserProjectMapper.selectById(aLong);
    }

    @Override
    public int selectUserProjectAlreadyExists(Long userId, Long projectId) {
        return elsUserProjectMapper.selectUserProjectAlreadyExists(userId,projectId);
    }

}
